﻿using System;
using System.Collections.Generic;


namespace HAVNet.Intros.AST
{
    public class ASTEmbStmtTry : ASTEmbStmt
    {
        public ASTBlock tryBlock        { get; set; }
        public readonly ASTCatchs catchs = new ASTCatchs ();
        public ASTBlock finallyBlock    { get; set; }

        public override string ToString ()
        {
            if (finallyBlock == null)
            {
                return
                    "try"   + Environment.NewLine +
                    tryBlock+ Environment.NewLine +
                    catchs  + Environment.NewLine;
            }
            else
            {
                return
                    "try"   + Environment.NewLine +
                    tryBlock+ Environment.NewLine +
                    catchs  + Environment.NewLine + 
                    "finally"+ Environment.NewLine +
                    finallyBlock;
            }
        }
    }
}
